<template>
	<view class="index">
		<mescroll-uni ref="mescrollRef" height="100%" @init="mescrollInit" :down="downOption" @down="downCallback"
			:up="upOption" @up="upCallback">
			<!-- 数据列表 -->
			<view class="item" v-for="(item,index) in list" :key="index" @click="goDetail(item)">
				<view class="supplier-wrapper">
					<view class="supplier-info">
						<view class="name">违约日期：{{ item.fineTime }}</view>
						<!-- <uni-icons v-if="item.supplierTel" type="phone" size="18" class="icon"
							color="#434343"></uni-icons> -->
						<!-- <text class="tel" @click.stop="callPhone(item.supplierTel)">{{ item.supplierTel }}</text> -->
					</view>
					<!-- 					<view class="supplier-address">
						{{ item.businessAddress }}
					</view> -->
				</view>
				<view class="product-info">
					<view class="info-wrapper" style="justify-content: space-between;">
						<text>违约款金额：{{ item.pickupPointFineAmount }}元</text>
						<!-- <uni-icons type="right" color="#999999" size="16"></uni-icons> -->
					</view>
					<view class="info-wrapper">
						违约原因：{{ item.reason }}
					</view>
				</view>
				<view class="btn-wrapper">
					<view class="btn" @click="goAfterSale(item.afterSalesId)">
						查看售后单
					</view>
				</view>
			</view>
		</mescroll-uni>
	</view>
</template>

<script>
	import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
	export default {
		mixins: [MescrollMixin],
		data() {
			return {
				downOption: {
					auto: true // 不自动加载 (mixin已处理第一个tab触发downCallback)
				},
				upOption: {
					auto: false, // 不自动加载
					textNoMore: '没有更多啦~',
					noMoreSize: 2, //如果列表已无数据,可设置列表的总数量要大于半页才显示无更多数据;避免列表数据过少(比如只有一条数据),显示无更多数据会不好看; 默认5
					empty: {
						fixed: true,
						top: '200upx',
						tip: '~ 空空如也 ~', // 提示
						icon: 'https://sm.hobon.cc/static/hobon_noorder.png'
					}
				},
				isLoading: true,
				list: [],
				pageNum: 1,
				pageSize: 10,
			}
		},
		mounted() {

		},
		methods: {
			/*下拉刷新的回调 */
			downCallback() {
				// 这里加载你想下拉刷新的数据, 比如刷新轮播数据
				// loadSwiper();
				// 下拉刷新的回调,默认重置上拉加载列表为第一页 (自动执行 page.num=1, 再触发upCallback方法 )
				this.mescroll.resetUpScroll()
			},
			/*上拉加载的回调: 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10 */
			async upCallback(page) {
				//let status = ['1', '2', '10', '11', '3']
				this.pageNum = page.num;
				const params = {
					pageNum: this.pageNum,
					pageSize: this.pageSize,
					pickupPointId: this.$store.state.userInfo.pickupPointId,
					orders: [{
						"asc": false,
						"column": "id"
					}],
				};
				const data = await this.$api.post('/app/fine/page', params, false)
				if (data.code === 200) {
					this.isLoading = false;
					if (this.pageNum === 1) {
						this.list = [];
					}
					this.list = this.list.concat(data.data.records);
					this.mescroll.endBySize(data.data.records.length, data.data.total);
				} else {
					this.mescroll.endErr();
				}
			},
			goAfterSale(id) {
				uni.navigateTo({
					url: '/subPage_afterSale/detail?id=' + id
				})
			}
		},
		components: {

		}
	}
</script>

<style lang="scss" scoped>
	.index {
		height: 100%;
		overflow: hidden;

		.item {
			margin: 20upx;
			border-radius: 20upx;
			background-color: #ffffff;
			overflow: hidden;

			.supplier-wrapper {
				padding: 20upx 30upx;
				background-color: #F5F6FA;

				.supplier-info {
					display: flex;
					align-items: center;
					margin-bottom: 10upx;
				}

				.supplier-address {
					font-size: 30upx;
					color: #666666;
				}

				.name {
					flex: 1;
					font-size: 34upx;
					//width: 500rpx;
					text-overflow: -o-ellipsis-lastline;
					overflow: hidden; //溢出内容隐藏
					text-overflow: ellipsis; //文本溢出部分用省略号表示
					display: -webkit-box; //特别显示模式
					-webkit-line-clamp: 1; //行数
					line-clamp: 1;
					-webkit-box-orient: vertical; //盒子中内容竖直排列
					font-weight: bold;
					color: #343434;
				}

				.tel {
					font-size: 32upx;
					color: #343434;
				}
			}

			.product-info {
				overflow: hidden;
				padding: 0 30upx;

				.productName-wrapper {
					margin-top: 20upx;
					display: flex;
					align-items: center;

					.productName {
						flex: 1;
						font-size: 32upx;
						line-height: 38upx;
						//width: 500rpx;
						text-overflow: -o-ellipsis-lastline;
						overflow: hidden; //溢出内容隐藏
						text-overflow: ellipsis; //文本溢出部分用省略号表示
						display: -webkit-box; //特别显示模式
						-webkit-line-clamp: 2; //行数
						line-clamp: 2;
						-webkit-box-orient: vertical; //盒子中内容竖直排列
						font-weight: bold;
						color: #464646;
					}
				}

				.info-wrapper {
					display: flex;
					align-items: center;
					margin-top: 15upx;
					font-size: 32upx;
					color: #434343;

					.label {
						width: 130upx;
					}
				}
			}

			.btn-wrapper {
				display: flex;
				justify-content: flex-end;
				padding: 20upx 30upx;
				border-top: 1upx solid #E5E5E5;
				margin-top: 30rpx;

				.btn {
					width: 220upx;
					height: 70upx;
					line-height: 70upx;
					text-align: center;
					font-size: 30upx;
					color: #ffffff;
					background-color: #0D8EFF;
					border-radius: 10upx;
				}
			}
		}
	}
</style>